﻿@model Isaac.Joy.Identity.Web.DtCms.Models.RoleListViewModel
@{
    ViewBag.Title = "角色管理";
    Layout = Url.BundleContent("~/Views/Shared/_Layout.cshtml");
    Model.PageInfor.PageUrl = ((index, size) => Url.Action("Index", new { pi = index, ps = size }));
}
<div class="location">
    <a href="javascript:history.back(-1);" class="back"><i></i><span>返回上一页</span></a>
    <a class="home"><i></i><span>控制面板</span></a>
    <i class="arrow"></i>
    <span>角色管理</span>
</div>
<!--/导航栏-->

<!--工具栏-->
<div class="toolbar-wrap">
    <div id="floatHead" class="toolbar">
        <div class="l-list">
            <ul class="icon-list">
                <li><a class="add" href="@Url.Action("Add")"><i></i><span>新增</span></a></li>
                <li><a class="all" href="script:;" onclick="checkAll(this);"><i></i><span id="txtall">全选</span></a></li>
                @*<li><a id="btnSave" class="save" href="javascript:;"><i></i><span>保存</span></a></li>*@
                <li><a id="btnDelete" class="del" href="javascript:;"><i></i><span>删除</span></a></li>
            </ul>
        </div>
    </div>
</div>
<!--/工具栏-->

<!--文字列表-->

<table width="100%" border="0" cellspacing="0" cellpadding="0" class="ltable">
    <tr>
        <th width="6%">选择</th>
        <th align="left">角色名称</th>
        <th width="8%">操作</th>
    </tr>
    @{ var rowindex = 0; }
    @foreach (var role in Model.Data)
    {
        <tr>
            @{
        var rowctlid = "rptList_hidId_" + @rowindex;
        var rowchkid = "rptList_chkId_" + @rowindex;
        rowindex++;
            }
            <td align="center">
                <span class="aspNetDisabled checkall" style="vertical-align: middle;">
                    @if (role.FlagsValue.Enabled(0))
                    {
                        <input id="@rowchkid" type="checkbox" disabled="disabled" name="rptList$ctl01$chkId" />
                    }
                    else
                    {
                        <input id="@rowchkid" type="checkbox" name="rptList$ctl01$chkId" />
                    }
                </span>
                <input type="hidden" name="rptList$ctl01$hidId" id="@rowctlid" value="@role.Id" />
            </td>
            <td>
                <a href="@Url.Action("Edit", new { id = role.Id })">@role.Name</a>
            </td>
            <td align="center">
                @if (!role.FlagsValue.Enabled(0))
                {
                    <a href="@Url.Action("Edit", new { id = role.Id })">修改</a>
                }
            </td>
        </tr>
    }

</table>

<!--/文字列表-->

<!--图片列表-->

<!--/图片列表-->

<!--内容底部-->
<div class="line20"></div>
@{
    Html.RenderPartial("Page");
}
<!--/内容底部-->

@section scripts{
    <script type="text/javascript">
        $(function () {
            $("#btnDelete").click(function () {
                var delString = "";
                for (var i = 0; i < $("#txtPageNum").val() ; i++) {
                    if ($("#rptList_chkId_" + i).is(':checked') == true) {
                        var delStr = $("#rptList_hidId_" + i).val();
                        delString += delStr + ",";
                    }
                }
                if (delString != "") {
                    $.get("@Html.Raw(Url.Action("AjaxDelete"))", { strId: delString }, function (response) {
                    var data = JSON.parse(response);
                    errorCode.getMsg(data, function () {
                        if (data.success) {
                            $.dialog.alert('删除成功！', function () {
                                document.location.reload();
                            }, null, "提示");
                        } else {
                            $.dialog.alert('删除失败！');
                        }
                    }, function (e) {
                        $.dialog.alert(data.msg == '' ? e.msg : data.msg);
                    });
                }, 'text');
            } else {
                $.dialog.alert('请选择要删除的项');
            }
        });
    });
    </script>

}